package com.lb.client;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * 客户端配置类
 *
 * @author xiemingzhi
 * @since 1.0
 */
@Configuration
@ComponentScan({"com.lb.client"})
public class ClientConfiguration {

    @Configuration
    public static class restTemplateConfiguration {

        @Bean
        public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
            return new RestTemplate(factory);
        }

        @Bean
        public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
            SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
            factory.setReadTimeout(150000); // ms
            factory.setConnectTimeout(150000); // ms
            return factory;
        }
    }


}
